package com.gitee.wsl.io.dataproxy


open class ArrayProxy<T>(val list: Array<T>) : DataProxy<T> {

    override fun iterator() = list.iterator()

    override val size: Int get() = list.size

    override fun get(index: Int): T = list[index]

    override fun set(index: Int, value: T) {
        list[index] = value
    }

    override fun fill(value: T, fromIndex: Int, toIndex: Int) {
        list.fill(value, fromIndex, toIndex)
    }

    override fun values(): List<T> = list.toList()
}

fun<T> Array<T>.asProxy() = ArrayProxy(this)